package cn.wei.sdd.core.controller.admin;


import cn.wei.common.result.R;
import cn.wei.sdd.core.mapper.WarehouseProductMapper;
import cn.wei.sdd.core.pojo.query.WarehouseProductQuery;
import cn.wei.sdd.core.pojo.vo.WarehouseProductVO;
import cn.wei.sdd.core.service.WarehouseProductService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 商品库存表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-11-04
 */
@RestController
@Api(tags = "库存管理")
@RequestMapping("/admin/core/warehouseProduct")
public class AdminWarehouseProductController {

    @Resource
    private WarehouseProductService warehouseProductService;

    @ApiOperation("获取库存列表")
    @GetMapping("stockList/{page}/{limit}")
    public R listPage(@ApiParam(value = "当前页码数",required = true)
                      @PathVariable("page") Long page,
                      @ApiParam(value = "每页记录数",required = true)
                      @PathVariable("limit") Long limit,
                      @ApiParam(value = "搜索对象",required = false)
                              WarehouseProductQuery warehouseProductQuery){

        Page<WarehouseProductVO> pageParam = new Page<>(page, limit);
        IPage<WarehouseProductVO> pageModel =  warehouseProductService.listPage(pageParam,warehouseProductQuery);


        return R.ok().data("pageModel",pageModel);
    }

}

